package com.jay.compass.dialog;

import com.jay.compass.R;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class LocationInfoDialog extends Dialog {

	private TextView mLatTextView;
	private TextView mLngTextView;

	private Button cancelButton;
	private Button mapButton;
	private float mLat;
	private float mLng;

	public LocationInfoDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		setThisDialog();
		setTitle("北斗定位信息");
	}

	public float getLat() {
		return mLat;
	}

	public float getLng() {
		return mLng;
	}

	public void setLocation(float lat, float lng) {
		mLat = lat;
		mLng = lng;
		mLatTextView.setText("北纬：" + lat);
		mLngTextView.setText("东经：" + lng);
	}

	private void setThisDialog() {
		View mView = LayoutInflater.from(getContext()).inflate(
				R.layout.dialog_location_info, null);
		cancelButton = (Button) mView.findViewById(R.id.dialog_close_button);
		mapButton = (Button) mView.findViewById(R.id.dialog_map_button);

		mLatTextView = (TextView) mView.findViewById(R.id.lat_textView);
		mLngTextView = (TextView) mView.findViewById(R.id.lng_textView);

		super.setContentView(mView);

		cancelButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});
	}

	public void setMapOnClick(View.OnClickListener listener) {
		mapButton.setOnClickListener(listener);
	}
}
